<?php

namespace app\adminapi\controller\system;

use app\adminapi\service\SysFileCateService;
use app\adminapi\validate\SysFileCateValidate;
use app\common\controller\BaseAdminController;

class SysFileCateController extends BaseAdminController
{
    public array $notNeedLogin = [];

    public function list()
    {
        $param =  (new SysFileCateValidate())->get()->goCheck('list');
        $result = (new SysFileCateService())->list($param);
        return app('json')->successWithData($result);
    }

    /**
     * @title 新增文件分类
     * @businessType INSERT
     */
    public function insert()
    {
        $param = (new SysFileCateValidate())->post()->goCheck('insert');
        $result = (new SysFileCateService())->addSysFileCate($param);
        return app('json')->successWithData($result);
    }

    public function query()
    {
        $param = (new SysFileCateValidate())->get()->goCheck('query');
        $result = (new SysFileCateService())->getSysFileCate($param['id']);
        return app('json')->successWithData($result);
    }

    /**
     * @title 修改文件分类
     * @businessType UPDATE
     */
    public function update()
    {
        $param = (new SysFileCateValidate())->put()->goCheck('update');
        $result = (new SysFileCateService())->updateSysFileCate($param);
        return app('json')->successWithData($result);
    }

    /**
     * @title 删除文件分类
     * @businessType UPDATE
     */
    public function delete()
    {
        $param = (new SysFileCateValidate())->delete()->goCheck('delete');
        $result = (new SysFileCateService())->deleteSysFileCate($param['id']);
        return app('json')->successWithData($result);
    }
}